package com.heima.leetcode.practice;

/**
 * @description: leetcode 283. 移动零
 * @author 勾新杰
 * @version 1.0
 * @date 2025/2/13 9:17
 */
public class E283 {

    /**
     * 遍历数组，将非零数字移动到数组前面，将零移动到数组后面
     * @param nums 待处理的数组
     */
    public void moveZeroes(int[] nums) {
        int index = 0;
        for (int num : nums)
            if (num != 0)
                nums[index++] = num;
        while (index < nums.length) nums[index++] = 0;
    }
}
